<?

include('sys/init.php');

$what = (isset($_POST['what'])) ? $_POST['what'] : '';


// user registration

if($what=='register' && _registration_enabled && isset($_POST['l']) && isset($_POST['n']) && isset($_POST['e']) && isset($_POST['p']) )
{
   $user = new_user_array();

   $user['login'] = check_login($_POST['l']);
   $user['name']  = check_name ($_POST['n'], 'and check length, pls');
   $user['email'] = check_email($_POST['e']);
   $user['comment'] = justwords($_POST['c']);

   if( $user['login'] && $user['name'] && check_password($_POST['p']) )
   {
      $user['pass'] = md5($_POST['p']);
      $user['ban'] = (_register_as_blocked) ? 1 : 0;

      $res = edit_user_info($user);

      if($res=='error') go_back();
      else
      {
         global $_mss_register_success, $_mss_notify_admin_on_register;

         //sendemail($user, $_mss_register_success);

         $_mss_notify_admin_on_register['text'] .= $user['name']. '('. _basedomain.'/users/'. $user['login']. ')';

         message2admin($_mss_notify_admin_on_register);
         
         die( str_replace('_BASEDOMAIN_', _basedomain, get_template('user_register_complete.html')) );
      }

   }
   else go_back();
}

elseif( isset($_GET['registeruser']) && _registration_enabled )
{
   $user = new_user_array();

   $user['login'] = (isset($_POST['l'])) ? check_login($_POST['l']) : '';
   $user['name']  = (isset($_POST['n'])) ? check_name ($_POST['n'], 'check length, pls') : '';
   $user['email'] = (isset($_POST['e'])) ? check_email($_POST['e']) : '';
   $user['comment'] = (isset($_POST['c'])) ? justwords($_POST['c']) : '';

   die( html_registerform($user) );
}

?>
